     AddCSLuaFile( "cl_init.lua" )
     AddCSLuaFile( "shared.lua" )
      
     include('shared.lua')
	 
	function watermelonCount()
		local wms = ents.FindByClass("colonies_watermelon")
		return #wms
	end
	 
	 function ENT:SpawnFunction( ply, tr)
		local SpawnPos = tr.HitPos
		local ent = ents.Create( "colonies_watermelonplant" )
		ent:SetPos( SpawnPos )
		ent:Spawn()
		return ent
	end

      
    function ENT:Initialize()
		
		self.Entity:SetModel("models/props_foliage/shrub_01a.mdl")
		self.Entity:PhysicsInit( SOLID_VPHYSICS ) // Make us work with physics,
		self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) // after all, gmod is a physics
		self.Entity:SetSolid( SOLID_VPHYSICS ) // Toolbox 
		
		self.lastmelon = math.Round(CurTime())
    end
     
     function ENT:OnTakeDamage(dmg)
    
     end
	 	    
	function ENT:Think()
		if math.Round(CurTime()) > self.lastmelon + GetConVarNumber("co_watermelon_time") and watermelonCount() <= GetConVarNumber("co_watermelon_max") then
			local melon = ents.Create("colonies_watermelon")
			local dist = GetConVarNumber("co_watermelon_distance")
			melon:SetPos(self.Entity:GetPos()+Vector(math.random(-dist,dist),math.random(-dist,dist),15))
			melon:Spawn()
			self.lastmelon = math.Round(CurTime())
		end
	end 